
package system.communication;

import system.ui.Engine;

/**
 * This class polls the physical HandController for its status through the Monitor.
 *
 * @author elliot
 */
public class HandControlPoller extends Thread
{
    private boolean handControlOn = false;

    /**
     * Default Constructor.
     */
    public HandControlPoller()
    {
        
    }

    @Override
    public void run()
    {
        handControlOn = true;
        while(handControlOn)
        {
            switch(Engine.getInstance().getHandControlState())
            {
                case 1:
                    Monitor.getInstance().getHandControlStatus(1);
                    break;
                case 2:
                    Monitor.getInstance().getHandControlStatus(2);
                    break;
                case 3:
                    Monitor.getInstance().getHandControlStatus(1);
                    Monitor.getInstance().getHandControlStatus(2);
                    break;
                default:
                    break;
            }
            try
            {
                Thread.sleep(500);
            }
            catch (InterruptedException ex)
            {
                System.err.println(ex.getMessage());
                ex.printStackTrace();
            }
        }
    }

    public synchronized void end()
    {
        handControlOn = false;
    }

}
